# PowerShell启动脚本 - 支持UTF-8编码
# 设置控制台编码
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::InputEncoding = [System.Text.Encoding]::UTF8

# 设置PowerShell编码
$PSDefaultParameterValues['*:Encoding'] = 'utf8'

# 清理控制台
Clear-Host

# 设置环境变量
$env:JAVA_OPTS = "-Dfile.encoding=UTF-8 -Dconsole.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -Dspring.output.ansi.enabled=never"
$env:MAVEN_OPTS = "-Dfile.encoding=UTF-8 -Duser.timezone=Asia/Shanghai"
$env:LANG = "zh_CN.UTF-8"

Write-Host "===================================" -ForegroundColor Green
Write-Host "   PDF Document Converter Service  " -ForegroundColor Green  
Write-Host "===================================" -ForegroundColor Green
Write-Host ""
Write-Host "正在启动PDF文档转换器服务..." -ForegroundColor Yellow
Write-Host "Starting PDF Document Converter..." -ForegroundColor Yellow
Write-Host ""

# 启动应用
try {
    & mvn spring-boot:run
} catch {
    Write-Host "启动过程中发生错误: $($_.Exception.Message)" -ForegroundColor Red
}

Write-Host ""
Write-Host "服务已停止，按任意键退出..." -ForegroundColor Cyan
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")